<?php

/**
 * Versement form base class.
 *
 * @method Versement getObject() Returns the current form's model object
 *
 * @package    SdCommerce
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseVersementForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                 => new sfWidgetFormInputHidden(),
      'date'               => new sfWidgetFormDate(),
      'reference'          => new sfWidgetFormInputText(),
      'montant_total'      => new sfWidgetFormInputText(),
      'numero'             => new sfWidgetFormInputText(),
      'id_compte_bancaire' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('CompteBancaire'), 'add_empty' => true)),
      'id_caisse'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Caisse'), 'add_empty' => false)),
      'compte_comptable'   => new sfWidgetFormInputText(),
      'created_at'         => new sfWidgetFormDateTime(),
      'updated_at'         => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                 => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'date'               => new sfValidatorDate(),
      'reference'          => new sfValidatorString(array('max_length' => 20)),
      'montant_total'      => new sfValidatorNumber(),
      'numero'             => new sfValidatorInteger(array('required' => false)),
      'id_compte_bancaire' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('CompteBancaire'), 'required' => false)),
      'id_caisse'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Caisse'))),
      'compte_comptable'   => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'created_at'         => new sfValidatorDateTime(),
      'updated_at'         => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('versement[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Versement';
  }

}
